//
//  TileSet.m
//  ShiningEditor
//
//  Created by Jin Hu on 2010/08/18.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "TileSet.h"
#import "Tile.h"
#import "Buffer.h"

@implementation TileSet


- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Initialization code
    }
    return self;
}


- (void)dealloc {
    [super dealloc];
}

-(id)init: (NSString*)sourcefile andSize:(int)size
{	//Constructor

	UIImage* img =[UIImage imageNamed:sourcefile];
	int row = img.size.height/size;
	int col = img.size.width/size;
	[super initWithImage:img withRow:row andColumn:col mirror:false];
	tiles = [NSMutableArray arrayWithCapacity:(row*col)];
    return self;
	
}
	
-( Tile*) getTile:(int) index {
		return [tiles objectAtIndex:index];
	}
	
	- (void )addTile
	{
		[tiles addObject:[[Tile alloc]  init] ];
	}
	
- (void) setTile:(int )index tile:(Tile*) tile {
		[tiles replaceObjectAtIndex:index withObject:tile];
	}
@end
